#pragma once

#include "2d/CCNode.h"
#include "ui/UIPageView.h"
#include "ui/UIWidget.h"

class CCocosUiHelper
{
public:
	CCocosUiHelper(void);
	~CCocosUiHelper(void);

	static cocos2d::Node* seekNodeByTag(cocos2d::Node* root, int tag);
	static cocos2d::Node* seekNodeByName(cocos2d::Node* root, const std::string& name);
};

class CCocosCover : public cocos2d::Ref {
public:
	typedef cocos2d::ui::Widget::ccWidgetTouchCallback	PageViewCallBack_t;
public:
	CCocosCover();
	virtual ~CCocosCover();
	void SetPageView(cocos2d::ui::PageView* page);
	void SetCallback(const PageViewCallBack_t& callback) { m_Callback = callback; }
	cocos2d::ui::PageView* GetPageView() const { return m_Page; }
private:
	void onPageTouch(cocos2d::Ref* pSender, cocos2d::ui::TouchEventType type);
	void onPageEvent(cocos2d::Ref* pSender, cocos2d::ui::PageView::EventType type);
private:
	cocos2d::ui::PageView*			m_Page;
	cocos2d::Size					m_PageSize;
	cocos2d::Size					m_ShrinkSize;
	cocos2d::Vec2					m_LeftMove;
	cocos2d::Vec2					m_RightMove;

	std::vector<int32_t>			m_PageIndex;
	cocos2d::Vec2					m_StartPos;
	cocos2d::Vec2					m_TouchPos;
	ssize_t							m_CurIndex;
	cocos2d::Vec2					m_LeftPos;
	cocos2d::Vec2					m_MiddlePos;
	cocos2d::Vec2					m_RightPos;

	PageViewCallBack_t				m_Callback;
};

